<%layout("/common/_layout.html"){ %>
<script type="text/javascript">
var keywordsObj = {};
var submit_search = function(){
    if($("#name").val())
      keywordsObj.name = $("#name").val();
    if($("#list_select_type").val())
      keywordsObj.list_select_type = $("#list_select_type").val();
    var keywords = "";
    if(!$.isEmptyObject(keywordsObj)){
      keywords = JSON.stringify(keywordsObj);
    }
    $("#keywords").val(keywords);
    $("#list-form").submit();
}

var delete_theme = function(url){
	var $idsCheckedCheck = $("[name='ids']:checked");
    var $deleteButton = $("#deleteButton");// 删除按钮
    var ids = $idsCheckedCheck.serialize();
	if(window.confirm('你确定要删除选中数据吗？')){
		$.ajax({
	        url : url,
	        data : ids,
	        dataType : "json",
	        async : false,
	        beforeSend : function(data) {
                $deleteButton.prop("disabled", true)
            },
	        success : function(data) {
	        	$deleteButton.prop("disabled", false)
	            if(data.resultCode==1000){
	            	//alert(data.message);
	            	sendMessage({
      	              title : "删除!",
      	              text : data.message,
      	              type : data.status,
      	              timer : 2000,
      	              showConfirmButton : false
      	            });
                    submit_search();
	            }else{
	            	var msg = data.message;
	            	if(!msg){
	            		msg = "删除失败！"
	            	}
	            	sendMessage({
      	              title : "删除!",
      	              text : msg,
      	              type : data.status,
      	              timer : 2000,
      	              showConfirmButton : false
      	            });
	            }
	        }
	        
	    });
     }
}

</script>

<%#ajax userTable:{%>
<div class="am-cf am-padding">
  <div class="am-fl am-cf"> <strong class="am-text-primary am-text-lg" onclick="location.href='${base}/spreadMemberAuthConfig/businessList';">系统管理</strong>
    /
    <small>泛店员业务权限配置</small>
     /
    <small>已配置权限列表</small>
  </div>
</div>

<div class="am-g">
	<%include("business_auth_config_query.tpl"){}%>
	<div class="am-u-sm-12 am-u-md-12"
		style="padding: 0 1.6rem 1.6rem 1rem; margin: 0;">
		<div class="am-btn-toolbar" style="padding-left: .5rem;">
			<div class="am-btn-group am-btn-group-xs">
				<div class="am-btn-group am-btn-group-xs am-form-file">
					<%if(so.hasPermission("SM_BUS_AUTH_ADD")) {%>
						<button type="button" id="bt_add" class="am-btn"
							onclick="location.href='${base}/spreadMemberAuthConfig/addBusinessAuthConfig'">
							<span class="am-icon-plus"> 新增配置</span>
						</button>
					<%}%>
			        <%if(so.hasPermission("SM_BUS_AUTH_DELETE")) {%>
			            <button type="button" id="deleteButton" disabled="disabled" class="am-btn am-btn-default" onclick="delete_theme('${base}/spreadMemberAuthConfig/deleteBusinessAuthConfig')"><span class="am-icon-trash-o"></span> 删除</button>
			        <%}%> 
				</div>
			</div>
		</div>
	</div>
</div>

	<div class="am-g">
		<div class="am-u-sm-12">
			<div class="am-scrollable-horizontal">
				<table class="am-table am-table-striped am-table-hover table-main" style="TABLE-LAYOUT: fixed">
					<thead>
						<tr class="am-text-nowrap">
						    <th class="table-check"><input type="checkbox" id="allCheck"></th>
							<th class="table-title">业务名称</th>
							<th class="table-title">业务类型</th>
							<th class="table-title">机构</th>
							<th class="table-title">操作</th>
						</tr>
					</thead>
					<tbody>
						<%for(item in pager.list!){%>
						<tr>
						    <td>
								<!--<%if(curr_org_id!=item.creator_org_id){%>
								<input type="checkbox" name="orthers" checked="true" disabled='disabled' /></td>
								<%}%>-->
								<%if(curr_org_id==item.creator_org_id){%>
								<input type="checkbox"<%{%>name="ids" value="${item.config_business_id}#%#${item.creator_org_id}"<%}%> /></td>
								<%}%>

							<td style="word-wrap:break-word;">${item.name}</td>
							<td style="word-wrap:break-word;">${item.type_name}</td>
							<td style="word-wrap:break-word;">${item.DisplayName}</td>
							<td>
								<div class="am-btn-toolbar">
									<div class="am-btn-group am-btn-group-xs">
										<%if(so.hasPermission("SM_BUS_AUTH_EDIT")) {%>
                                        <div style="float: left">
                                            <button type="button"
											<%if(curr_org_id!=item.creator_org_id){%>
												disabled='disabled'
											<%}%>
                                            class="am-btn am-btn-default am-btn-xs am-text-secondary"
                                            onclick="location.href='${base}/spreadMemberAuthConfig/editBusinessAuthConfig?config_business_id=${item.config_business_id}&creator_org_id=${item.creator_org_id}&config_business=${item.config_business}'">
                                            <span class="am-icon-pencil-square-o"></span>授权
                                            </button>&nbsp;&nbsp;
                                        </div>
                                        <%}%>
									</div>
								</div>
							</td>

						</tr>
						<%}%>
					</tbody>
				</table>
			</div>

			<div class="am-cf">
				<!-- 分页 -->
				<%if (pager.list.~size > 0){%>
				<div class="am-fr"><% include("/admin/common_pager.tpl"){}%></div>
				<%}else{%>
				<div class="am-kai">
					<h3>没有找到任何记录!</h3>
				</div>
				<%}%>
			</div>

		</div>
	</div>
	<div class="am-modal am-modal-no-btn" tabindex="-1" id="modal">
		<div class="am-modal-dialog">
			<div class="am-modal-hd">
				<i class="am-icon-refresh am-icon-spin"></i> <a
					href="javascript: void(0)" class="am-close am-close-spin"
					data-am-modal-close>&times;</a>
			</div>
			<div class="am-modal-bd">正在处理，请稍等...</div>
		</div>
	</div>
	<%}%> <%}%>